package thread;

public class SleepDemo implements Runnable{
	public void run() {
		for(int i =1;i<6;i++){
			long l=0;
			l=System.currentTimeMillis();
			try {
				//不推荐使用
				//Thread.currentThread().sleep(5000);
				Thread.sleep(5000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			l=(System.currentTimeMillis()-l);
			System.out.println(Thread.currentThread().getName()+"线程执行了"+i+"次，耗时"+l+"毫秒");
		}
	}
	public static void main(String[] args) {
		SleepDemo sd = new SleepDemo();
		for(int i=0;i<10;i++){
			new Thread(sd,i+"#").start();
		}
	}
}
